$NG.AllReady(function (page, { useAction, useBeforeClick, useValuesChange, useClick, useUpdateRow, subscribe, useUpdateRows }) {
    const mstform = $NG.getCmpApi("baseInfo")
    const dgrid1 = $NG.getCmpApi("")
    const getHeadValue = (str) => mstform.getItem(str).getValue()

    useValuesChange(() => {
        getSupplyInfo()
    }, "PhidCustomerEnt")

    // 获取供应商信息
    function getSupplyInfo() {
        const phid = mstform.getItem("PhidCustomerEnt").getValue()
        if (!phid) return
        $NG.execServer("getSupplyInfo", { phid }, (res) => {
            if (res.count == 0) return
            const data = JSON.parse(res.data)[0].extendObjects
            const arr = [
                {
                    key: 'user_nsrsbh',
                    value: data.unisocialcredit
                },
                {
                    key: 'user_khh',
                    value: data.taxbank_name
                },
                {
                    key: 'user_zh',
                    value: data.taxaccountno
                },
                {
                    key: 'user_dz',
                    value: data.taxaddress
                },
                {
                    key: 'user_sj',
                    value: data.taxtelephone
                },
                {
                    key: 'user_lxr',
                    value: data.taxpayername
                },
                {
                    key: 'user_sx',
                    value: data.user_sx
                }, {
                    key: 'user_hh',
                    value: {
                        label: data.taxbank_no,
                        value: data.taxbank_id
                    }
                },
                {
                    key: "user_nsrlx",
                    value: data.taxpayertype
                }
            ]
            setHeadValue(arr)
        })
    }

    // 赋值
    function setHeadValue(datas) {
        datas.forEach(item => {
            try {
                mstform.getItem(item.key).setValue(item.value)
            } catch (err) {
                console.log(`err`, err, item);
            }
        })
    }
})
